import { Controller, Get, Request } from '@nestjs/common';
import { ApiUseTags } from '@nestjs/swagger';
import { ApiResult } from '../config/index';
import { NewsService } from './news.service';

@Controller('news')
@ApiUseTags('News管理')
export class NewsController {
  constructor(private readonly newsService: NewsService) {}

  @Get('test')
  async test(@Request() request): Promise<ApiResult> {
    // return ApiResult.SUCCESS(await this.newsService.fetchSituation());
    const res = await this.newsService.puppeteer();
    return ApiResult.SUCCESS(res);
  }

  @Get('list')
  async list(): Promise<ApiResult> {
    return ApiResult.SUCCESS(await this.newsService.list());
  }
}
